package com.yanqu.road.entity.union.activitygroup;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import org.apache.mina.util.ConcurrentHashSet;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_s_union_activity_group")
public class UnionActivityGroup extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "分组ID", update = true)
    private int groupId;
    @FieldTypeAnnotation(desc = "跨服ID")
    private int crossServerId;
    @FieldTypeAnnotation(desc = "涉及区服ID")
    private Set<Long> serverSet = new HashSet<>(); // 不要修改，直接set

    private ConcurrentHashMap<String, UnionActivityGroupUnion> unionDataMap = new ConcurrentHashMap<>();

    // 商会跨服才有
    private boolean syncCrossServer = false;                                        // 是否同步到活动跨服
    private ConcurrentHashSet<Long> noSyncServerSet = new ConcurrentHashSet<>();    // 未同步的区服


    // ------------------------------------------------------

    public void setCrossServerIdNeedSync(int crossServerId) {
        this.crossServerId = crossServerId;
        this.syncCrossServer = false;
    }

    public void setServerSetNeedSync(Set<Long> serverSet) {
        this.serverSet = serverSet;
        this.noSyncServerSet = new ConcurrentHashSet<>(serverSet);
    }

    // ------------------------------------------------------


    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public int getCrossServerId() {
        return crossServerId;
    }

    public void setCrossServerId(int crossServerId) {
        this.crossServerId = crossServerId;
    }

    public ConcurrentHashMap<String, UnionActivityGroupUnion> getUnionDataMap() {
        return unionDataMap;
    }

    public void setUnionDataMap(ConcurrentHashMap<String, UnionActivityGroupUnion> unionDataMap) {
        this.unionDataMap = unionDataMap;
    }

    public UnionActivityGroupUnion getGroupUnion(String unionUid){
        return this.unionDataMap.get(unionUid);
    }

    public Set<Long> getServerSet() {
        return serverSet;
    }

    public void setServerSet(Set<Long> serverSet) {
        this.serverSet = serverSet;
    }

    public boolean isSyncCrossServer() {
        return syncCrossServer;
    }

    public void setSyncCrossServer(boolean syncCrossServer) {
        this.syncCrossServer = syncCrossServer;
    }

    public ConcurrentHashSet<Long> getNoSyncServerSet() {
        return noSyncServerSet;
    }

    public void setNoSyncServerSet(ConcurrentHashSet<Long> noSyncServerSet) {
        this.noSyncServerSet = noSyncServerSet;
    }

}
